﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

namespace DSSDataServiceGenerator.Controls
{
    public partial class ModelDesignerItem
    {
        public ModelDesignerItem()
            : base()
        {
            InitializeComponent();
        }

        private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            if (sender is Thumb)
            {
                UIElement item = this;//(UIElement)(sender as Thumb).TemplatedParent;

                double top = Canvas.GetTop(item);

                double left = Canvas.GetLeft(item);

                top = (double.IsNaN(top)) ? 0.0 : top;

                left = (double.IsNaN(left)) ? 0.0 : left;

                top += e.VerticalChange;

                left += e.HorizontalChange;

                top = Math.Round(top / 25.0) * 25;

                left = Math.Round(left / 25.0) * 25;

                Canvas.SetTop(item, top);

                Canvas.SetLeft(item, left);
            }
        }
    }
}